# 收藏商品

from selenium.webdriver.common.by import By
import time


class PageEcshopFrontCollection_Goods():
    '''收藏商品'''
    def __init__(self, driver):
        self.driver = driver

    # 定义定位器
    loc_front_secondarty_goods_cart = (By.XPATH, '//form[@id="ECS_FORMBUY"]/ul[2]/li[1]/dd/a[1]')

    # 点击收藏
    def front_secondarty_goods_cart(self):
        self.driver.find_element(*self.loc_front_secondarty_goods_cart).click()
        time.sleep(2)

    def front_jingao(self):
        textcl = self.driver.switch_to.alert.text  # 获得警告框内容

        time.sleep(2)
        self.driver.switch_to.alert.accept()  # 确定警告框

        return textcl



    def collection_goods(self):
        self.front_secondarty_goods_cart()
        self.front_jingao()